package org.dormi.learn;

import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import isva.IsvAModule;
import isvb.IsvBModule;
import org.dormi.learn.promotion.api.PromotionService;
import org.dormi.learn.promotion.model.Order;
import org.dormi.learn.promotion.model.Promotion;
import org.dormi.learn.promotion.model.PromotionResult;

/**
 * add description here
 *
 * @author : dormi330
 * @version : 1.0
 */
public class Runit {

    public static void main(String[] args) {
        runOneModule(new IsvAModule());
        runOneModule(new IsvBModule());
    }

    private static void runOneModule(AbstractModule module) {
        Injector injector = Guice.createInjector(module);
        PromotionService service = injector.getInstance(PromotionService.class);
        Order order = injector.getInstance(Order.class);
        Promotion promotion = injector.getInstance(Promotion.class);
        PromotionResult result = service.apply(order, promotion, null);
        System.out.println(result);
    }

}
